//
//  ShortVideoModel.swift
//  TestActorDownload
//
//  Created by 罗万能 on 2025/6/13.
//
import Foundation
import SwiftData

@Model
class ShortVideoModel:DownloadTaskForSwiftDataProtocol {
    var id: UUID
    
    var remoteURL: URL
    
    var localStoredFilePath: URL?
    
    var status: DownladStatus
    
    var resumeData: Data?
    
    var currentProcess: Double
    
   
    init?(data: Data){
        do{
            let decoder = JSONDecoder()
            let response = try decoder.decode(ShortVideoModelStruct.self, from: data)
            self.id = UUID()
            guard let url =  URL(string: response.link) else { return nil}
            self.remoteURL = url
            self.status = .queued
            self.currentProcess = 0
        }catch{
            print(error)
            return nil
        }
    }
    
}
struct ShortVideoModelStruct: Codable {
    var status : String
    var link: String
}
